﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OOLib
{
   /// <summary>
   /// Provides access to sub frames of current one.
   /// </summary>
   public class FramesSupplier : Component, IFramesSupplier
   {
       #region Constructors

      /// <summary>
      /// Constructor
      /// </summary>
      /// <remarks>
      /// After using this constructor, the ComObj must be set manually!
      /// </remarks>
      public FramesSupplier() :
         base()
      { }

      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="comObject">COM object</param>
      public FramesSupplier(object comObject) :
         base(comObject)
      { }

      #endregion

      #region IFramesSupplier

      /// <summary>
      /// Provides access to this container and to all other XFramesSupplier which are available from this node of frame tree
      /// </summary>
      /// <returns>The collection of frames which is represented by a FramesContainer.</returns>
      /// <remarks>!!! Not tested !!!</remarks>
      public Frames GetFrames()
      {
         CheckDisposed();
         return GetObjectWrapper<Frames>(InvokeMethod("getFrames"));
      }

      /// <summary>
      /// Gets or sets current active frame of this container (not of any other available supplier).
      /// </summary>
      /// <remarks>
      /// This may be the frame itself. The active frame is defined as the frame which contains (recursively) the window with the focus. 
      /// If no window within the frame contains the focus, this method returns the last frame which had the focus. 
      /// If no containing window ever had the focus, the first frame within this frame is returned.
      /// !!! Not tested !!!
      /// </remarks>
      public Frame ActiveFrame 
      { 
         get
         {
            CheckDisposed();
            return GetObjectWrapper<Frame>(InvokeMethod("getFrame"));
         }
         set
         {
            CheckDisposed();
            InvokeMethod("setFrame", value == null ? null : value.ComObj);
         }
      }

      #endregion
   }

   /// <summary>
   /// Provides access to sub frames of current one.
   /// </summary>
   public interface IFramesSupplier
   {
      /// <summary>
      /// Provides access to this container and to all other XFramesSupplier which are available from this node of frame tree
      /// </summary>
      /// <returns>The collection of frames which is represented by a FramesContainer.</returns>
      Frames GetFrames();

      /// <summary>
      /// Gets or sets current active frame of this container (not of any other available supplier).
      /// </summary>
      /// <remarks>
      /// This may be the frame itself. The active frame is defined as the frame which contains (recursively) the window with the focus. 
      /// If no window within the frame contains the focus, this method returns the last frame which had the focus. 
      /// If no containing window ever had the focus, the first frame within this frame is returned.
      /// </remarks>
      Frame ActiveFrame { get; set; }
   }
}
